<?php

/*
 * +----------------------------------------------------------------------
 * 作 者: xinglou <xinglou1@foxmail.com>
 * +----------------------------------------------------------------------
 * 创建日期：2012-12-19
 * +----------------------------------------------------------------------
 * 文件描述：
 * +----------------------------------------------------------------------
 * 升级记录：
 * +----------------------------------------------------------------------
 */
class CommonModel extends Model
{
    // 获取系统日期
    function getDate()
    {
        return date('Y-m-d H:i:s');
    }
    // 获取系统短日期
    function getShortDate()
    {
        return date('Y-m-d');
    }
    // 获取登录用户ID
    function getUserId()
    {
        return cookie('userid');
    }

    function getUserName()
    {
        return cookie('user_name');
    }

    function getUserRealName()
    {
        return cookie('user_real_name');
    }
    // 登录用户的当前角色
    function getUserType()
    {
        return cookie('current_role');
    }

    function getWebId()
    {
        return cookie('webid');
    }

    function getOperator()
    {
        return cookie('userid');
    }
    
    // 获取IP地址
    function getIP()
    {
        if (! empty($_SERVER["HTTP_CLIENT_IP"])) {
            $cip = $_SERVER["HTTP_CLIENT_IP"];
        } elseif (! empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
            $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
        } elseif (! empty($_SERVER["REMOTE_ADDR"])) {
            $cip = $_SERVER["REMOTE_ADDR"];
        } else {
            $cip = "无法获取！";
        }
        return $cip;
    }
}
?>